<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;

/**
 * 文件控制器
 * 主要用于文件上传和下载
 */

class FileController extends HomeController {
	/* 文件上传 */
	public function upload(){
		$return  = array('status' => '1', 'info' => '上传成功', 'url' => '');
        $upload = new \Think\Upload(C('DOWNLOAD_UPLOAD'));// 实例化上传类
        $info   = $upload->upload($_FILES);
        if(!$info) {// 上传错误提示错误信息
            $return['status'] = '0';
            $return['info']   = $upload->getError();
            $this->ajaxReturn($return);
        }else{// 上传成功 获取上传文件信息
            $return['url']='/Uploads/Download/'.$info['download']['savepath'].$info['download']['savename'];
            $this->ajaxReturn($return);
        }

	}


    /**
     *导出excel
     */
    public function exportExcel(){
        $uid=is_login();
        $map['introducer_id']=$uid;
        $map['type']=2;
        $status=I('get.status');
        if($status!='' && $status!=null){
            $map['status']=$status;
        }else{
            $map['status']=array('gt',-1);
        }
        $list=M('student_info')
            ->alias('a')
            ->join('vo_major as b ON a.major=b.id')
            ->field('a.id,a.name,a.ID_number,a.home_address,a.school,b.title,a.introducer,a.introducer_phone,a.pay_evidence,a.create_time,a.update_time,a.manage_update_time,a.status')
            ->where($map)
            ->select();
        foreach ($list as $k=>&$vo){
            $vo['create_time']=time_format($vo['create_time']);
            $vo['update_time']=time_format($vo['update_time']);
            $vo['manage_update_time']=time_format($vo['manage_update_time']);
            $vo['pay_evidence']=empty($vo['pay_evidence'])?"未缴费":'已缴费';
            if($vo['status']==0){
                $vo['status']='未审核';
            }else if($vo['status']==1){
                $vo['status']='已审核';
            }
        }
        exportexcel($list,array('编号','姓名','身份证号','家庭住址','毕业院校','专业','介绍人','介绍人电话','是否缴费','首次提交时间','最后一次修改时间','管理员修改时间','审核状态'),'info');
    }

}
